/**
 * 自定义数据表格
 */
(function($){
    $.fn.extend({
        biubiu : function(grid) {
        	
        	if(!grid || !grid.url) {
        		return;
        	}
        	
        	var $gridDom = $(this);
        	
        	var queryParam = grid.request;
        	queryParam.pageNo = 1;
        	queryParam.pageSize = 100;
        	queryParam.pageStart = (queryParam.pageNo - 1) * queryParam.pageSize;
        	
        	var loadingIndex = submitHolder();
			jsonAjax(grid.url, 'json', JSON.stringify(queryParam), function(data) {
				closeSubmitHolder(loadingIndex);
				if(data.status == SysConstant.SUCCESS) {
					var gridDatas = data.object.list;
		        	var columns = grid.columns;
		        	
		        	var table = $('<table class="table"></table>');
		        	var thead = $('<thead></thead>');
		        	var thead_tr = $('<tr></tr>');
		        	for(var i = 0; i < columns.length; i++) {
		        		if(i == 0) {
		        			thead_tr.append($('<th class="col-md-1">' + columns[i].dataText + '</th>'));
		        		} else {
		        			thead_tr.append($('<th>' + columns[i].dataText + '</th>'));
		        		}
		        	}
		        	thead.append(thead_tr);
		        	table.append(thead);
		        	
		        	var tbody = $('<tbody></tbody>');
		        	for(var i = 0; i < gridDatas.length; i++) {
		        		var tbody_tr = $('<tr></tr>');
		        		for(var j = 0; j < columns.length; j++) {
			        		tbody_tr.append($('<td>' + gridDatas[i][columns[j].dataName] + '</td>'));
			        	}
		        		tbody.append(tbody_tr);
		        	}
		        	table.append(tbody);
		        	
		        	$gridDom.html(table);
				} else {
					tipsFailed(data.msg, 1500);
				} 
			});
        }
    });
})(jQuery);